package com.dingwen.treasure.base.util;

import cn.hutool.core.date.DateUtil;

import java.util.Date;

/**
 * 中文星期转换工具
 *
 * @author dingwen
 * @date 2022/12/28
 */
public class DateChineseUtil {

    /**
     * 日期
     *
     * @param date 日期
     * @return {@link String}
     */
    public static String date(Date date){
        return DateUtil.formatChineseDate(date,false,false)
                .concat("   ")
                .concat(week(date));
    }

    /**
     * 得到中文星期几
     *
     * @param date 日期
     * @return {@link String}
     */
    public static String week(Date date) {
        switch (DateUtil.dayOfWeek(date)) {
            case 1:
                return "星期天";
            case 2:
                return "星期一";
            case 3:
                return "星期二";
            case 4:
                return "星期三";
            case 5:
                return "星期四";
            case 6:
                return "星期五";
            case 7:
                return "星期六";
            default:
                return null;
        }
    }
}
